//
//  MidouTableViewCell.m
//  markmap
//
//  Created by 甘世清 on 2024/6/18.
//

#import "MidouTableViewCell.h"

@implementation MidouTableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}
- (void)SQ_Style:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    
    UIView * bgView= [[UIView alloc]init];
    bgView.backgroundColor = SQColor(@"#6B6B6B");
    bgView.layer.cornerRadius = 12;
    bgView.layer.masksToBounds  = YES;
    [self.contentView addSubview:bgView];
    [bgView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.edges.equalTo(self.contentView).insets(UIEdgeInsetsMake(6, 16, 6, 16));
    }];
    self.bgimage = [[UIImageView alloc]init];
    self. bgimage.image = SQGetImage(@"midoubg");
    [self.contentView addSubview:self.bgimage];
    [self.bgimage mas_makeConstraints:^(MASConstraintMaker *make) {
            make.edges.equalTo(self.contentView).insets(UIEdgeInsetsMake(6, 16, 6, 16));
    }];
    
    UIImageView * douzi = [[UIImageView alloc]init];
    douzi.image = SQGetImage(@"豆子");
    [self.contentView addSubview:douzi];
    [douzi mas_makeConstraints:^(MASConstraintMaker *make) {
            make.size.mas_equalTo(20);
            make.left.equalTo(self.contentView).offset(36);
            make.centerY.equalTo(self.contentView);
    }];
    [self.contentView addSubview:self.midouLabel];
    [self.midouLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(douzi);
        make.left.equalTo(douzi.mas_right).offset(12);
    }];
    
    [self.contentView addSubview:self.moneyLabel];
    [self.moneyLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(douzi);
        make.right.equalTo(self.contentView.mas_right).offset(-40);
    }];
}
- (void)setModel:(MiDouModel *)model{
    _model = model;
    if (model.isseleted) {
        self.bgimage.hidden = NO;
    } else {
        self.bgimage.hidden = YES;
    }
    self.midouLabel .text = model.num;
    self.moneyLabel.text = [NSString stringWithFormat:@"%@%@",model.prefix,model.price];
    
}
- (UILabel *)midouLabel{
    if (!_midouLabel) {
        _midouLabel = [[UILabel alloc]init];
        _midouLabel.textColor = UIColor.whiteColor;
        _midouLabel.font = FONT_SEMIBOLD(16);
    }
    return _midouLabel;
}
- (UILabel *)moneyLabel{
    if (!_moneyLabel) {
        _moneyLabel = [[UILabel alloc]init];
        _moneyLabel.textColor = UIColor.whiteColor;
        _moneyLabel.font = FONT_MEDIUM(22);
    }
    return _moneyLabel;
}
@end
